﻿Imports System.Data
Imports System.Data.OleDb
Imports MetodosComuns
Imports extranet.BC
Imports extranet.BE
Imports System.Collections.Generic

Partial Class _Default
  Inherits System.Web.UI.Page

  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    '==============xxxxxxxxxxxxxxxxxxxxxxx==================
    'Eliminacion de las Notificaciones de cambios en archivos
    'Não Apagar !!!!!!!
    Dim p As System.Reflection.PropertyInfo = GetType(System.Web.HttpRuntime).GetProperty("FileChangesMonitor", _
                                                      System.Reflection.BindingFlags.NonPublic Or _
                                                      System.Reflection.BindingFlags.Public Or _
                                                      System.Reflection.BindingFlags.Static)

    Dim o As Object = p.GetValue(Nothing, Nothing)
    Dim f As System.Reflection.FieldInfo = o.GetType().GetField("_dirMonSubdirs", _
                                                                System.Reflection.BindingFlags.Instance Or _
                                                                System.Reflection.BindingFlags.NonPublic Or _
                                                                System.Reflection.BindingFlags.IgnoreCase)
    Dim monitor As Object = f.GetValue(o)
    Dim m As System.Reflection.MethodInfo = monitor.GetType().GetMethod("StopMonitoring", _
    System.Reflection.BindingFlags.Instance Or System.Reflection.BindingFlags.NonPublic)
    m.Invoke(monitor, New Object() {})
    ' Fim 
    '==============xxxxxxxxxxxxxxxxxxxxxxx==================

    If Not IsPostBack Then
      'Dim objNoticias As New BCNoticia
      Accordion1.DataSource = BCNoticia.Listar()
      Accordion1.DataBind()

      Dim objBERanking As BERanking = BCRanking.SelecionarRanking("1")

      grvRanking.DataSource = BCRankeado.LerRankeados(objBERanking.Planilha, True)
      grvRanking.DataBind()

      For i As Integer = 0 To grvRanking.Rows.Count - 1
        Select Case i
          Case 0
            Dim imgOuro As Image = grvRanking.Rows(i).FindControl("imgOuro")
            imgOuro.Visible = True
          Case 1
            Dim imgPrata As Image = grvRanking.Rows(i).FindControl("imgPrata")
            imgPrata.Visible = True
          Case 2
            Dim imgBronze As Image = grvRanking.Rows(i).FindControl("imgBronze")
            imgBronze.Visible = True
          Case Else
            Dim lblPos As Label = grvRanking.Rows(i).FindControl("lblPos")
            lblPos.Visible = True
            lblPos.Text = (i + 1).ToString()
        End Select
      Next

    End If
  End Sub

  Protected Sub btnLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLogin.Click
    If txtUsuario.Text.Length > 0 AndAlso txtSenha.Text.Length > 0 Then
      Dim objBEUsuario As BEUsuario = BCUsuario.SelecionarLogin(txtUsuario.Text, txtSenha.Text)
      If objBEUsuario.Usuario.Length > 0 Then
        Session("Logado") = True
        Session("objBEUsuario") = objBEUsuario
        If objBEUsuario.GrupoAcesso Is Nothing OrElse objBEUsuario.GrupoAcesso.IdGrupo = 0 Then
          lblErro.Visible = True
        ElseIf objBEUsuario.Usuario.ToUpper() = "ADMIN" Then
          Response.Redirect(MetodosComuns.GetVirtualPath & "/AdministracaoAcessos/AdmAcsTelas.aspx")
        ElseIf objBEUsuario.GrupoAcesso.Nome.ToUpper() = "ADMIN" Then
          Response.Redirect(MetodosComuns.GetVirtualPath & "/AdmPerfil.aspx")
        ElseIf objBEUsuario.GrupoAcesso.Nome.ToUpper() = "TRABALHECONOSCO" Then
          Response.Redirect(MetodosComuns.GetVirtualPath & "/trabalhe/cadastrarCurriculoCandidato.aspx")
        Else
          Response.Redirect(MetodosComuns.GetVirtualPath & "/PubEntrada.aspx")
        End If
      End If
    Else
      lblErro.Visible = True
    End If
  End Sub

  Protected Sub lb_EsqueciSenha_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lb_EsqueciSenha.Click
    Response.Redirect("~/LoginRecovery.aspx")
  End Sub

End Class
